package com.yjc.rabbitMQ.three;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.MessageProperties;
import com.yjc.rabbitMQ.utils.RabbitMQUtils;

import java.util.Scanner;

/**
 * @author shkstart
 * @create 2022-07-30 16:14
 */
public class Task02 {

    private static final String QUEUE_NAME = "Hello_queue_product *(￣▽￣)";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMQUtils.getChannel();
        boolean durable=true; //开启队列持久化
        channel.queueDeclare(QUEUE_NAME, durable, false, false, null);
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            System.out.println("请输入内容：");
            String content = sc.next();
            channel.basicPublish("", QUEUE_NAME, MessageProperties.PERSISTENT_TEXT_PLAIN/* 开启消息持久化(不是立即执行) */, content.getBytes("UTF-8"));

        }
    }
}
